package com.ymatou.iapi.productprice.testcase;

import com.shop2cn.iapi.activitymgt.parameter.AddactivityBean;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ImportAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ProductDetailsDto;
import com.ymatou.iapi.prodstock.parameter.PCatalogListDto;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.iapi.productprice.parameter.CatalogAllPriceBean;
import com.ymatou.iapi.productprice.parameter.PriceConfig;
import com.ymatou.iapi.productprice.parameter.ProductAllPriceBean;
import com.ymatou.iapi.productprice.parameter.ProductPriceBean;
import com.ymatou.iapi.productprice.service.GetCatalogPriceListByDeliveryExtraCall;
import com.ymatou.iapi.productprice.service.GetPriceByCatalogIdsCall;
import com.ymatou.iapi.productprice.service.GetPriceByProdIdCall;
import com.ymatou.iapi.userregister.parameter.UserRegisterInfoRequestDtoBean;
import com.ymatou.iapi.userregister.service.UserRegisterInfoRequestDtoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.*;
import com.ymttest.database.model.YmtCatalogsI;
import com.ymttest.database.mongo.jproduct.ActivityProductsWapper;
import com.ymttest.database.mongo.jproduct.ProductTimeStampWapper;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.utils.AgentUsers;
import com.ymttest.utils.YMTDateUtil;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.*;
import org.junit.experimental.categories.Category;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;

public class Ts_GetPriceByCatalogIds {
	
	//3332634	level 0	registerTime 2015-05-26 14:20:04
	private static int newBuyerId = ProductPriceCallService.getNewCustomer();
	
	//20238699	level 6	  registerTime 2016-04-22 10:19:05
	private static int oldBuyerId = ProductPriceCallService.getOldCustomer();
	
	private static GetPriceByCatalogIdsCall getPriceByCatalogIdsCall = new GetPriceByCatalogIdsCall();
	private static ProductTimeStampWapper productTimeStampWapper = new ProductTimeStampWapper();
	private static ActivityProductsWapper activityProductsWapper = new ActivityProductsWapper();
	// 渠道商
	private static int rootUserId = AgentUsers.rootUserId;
	private static String rootUserName = "NickautoTest";

	// 渠道商
	private static int sellerId = AgentUsers.rootUserId;
	private static String sellerName = "NickautoTest";
	// 渠道商->代理商1
	private static int agentUserId1 = AgentUsers.agentUserId1;
	private static String agentUserName1 = "NickautoTest";
	// 渠道商->代理商2
	private static int agentUserId2 = AgentUsers.agentUserId2;
	private static String agentUserName2 = "NickautoTest";

	private static GetPriceByProdIdCall getPriceByProdIdCall = new GetPriceByProdIdCall();

	private static GetCatalogPriceListByDeliveryExtraCall getCatalogPriceListByDeliveryExtraCall = new GetCatalogPriceListByDeliveryExtraCall();
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("非交易隔离查询接口, 根据商品catalogs list查询商品价格");
		try {
			GodfreightmgrService.deleteBySellerId(rootUserId);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Before
	public void caseUp() {
		
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getPriceByCatalogIdsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIds_001() {
		Logger.start(true, "非交易隔离,普通新人活动");
		try {

			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele->catalogs.add(ele.getCatalogId()));
			
			
			//1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
			JSONObject ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
			
			
			//2码头老客户查询结果为普通商品价格逻辑
			//vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
			JSONObject ret2 = getPriceByCatalogIdsCall .callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
			
			//not vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
			oldProductPrice = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
			ret2 = getPriceByCatalogIdsCall .callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于缓存里面没有该商品记录，所以结果应该查数据库
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean,inaid);
				
				//新客修改后价格检查 读缓存活动价格
				//是否用缓存
				ProductPriceBean newProductPriceUpdate = PriceConfig.isCacheActivityProduct?
													ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false):
														ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate,true,false);
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);
				
				//老客修改后价格检查 价格读库
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate,false);
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);
			
				
				//通过商品查价格，缓存该商品规格数据
				getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				
				
				//修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				ProductAllPriceBean productAllPriceBeanUpdate2 = ProductPriceCallService.updatePriceInMgo(productAllPriceBeanUpdate,inaid);
				
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				if ( PriceConfig.isCacheActivityProduct){
					ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
				}else{
					ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate2,true,false);
					ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);
				}
				
				
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
//				productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);

				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate2,true,false);
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);
				
				//老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate2 = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate2,false);
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate2);
			
				
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIds_002() {
		Logger.start(true, "非交易隔离,非新人活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele->catalogs.add(ele.getCatalogId()));
			
			//1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
			JSONObject ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
			
			//2码头老客户查询结果为活动价格
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,false);
			JSONObject ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于缓存里面没有该商品记录，所以结果应该查数据库
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean,inaid);
				
				//新客修改后价格检查
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				
				//老客修改后价格检查
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);

				if (PriceConfig.isCacheActivityProduct){
					ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
					ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
				}else{
					ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate,true,false);
					ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);
					
					ProductPriceBean oldProductPriceUpdate2 = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate,false,false);
					ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate2);
				}
				
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
//				productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);

				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate,true,false);
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);
				
				//老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate2 = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate,false,false);
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate2);
			
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIds_003() {
		Logger.start(true, "交易隔离,新人活动");
		try {

			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NewBuyerAndIsolation();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele->catalogs.add(ele.getCatalogId()));
			
			//1 码头新客户 查询结果为普通商品价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
			JSONObject ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
			
			
			//2码头老客户查询结果为普通商品价格
			
			//vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
			JSONObject ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
			
			//not vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
			oldProductPrice = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
			ret2 = getPriceByCatalogIdsCall .callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于缓存里面没有该商品记录，所以结果应该查数据库
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean,inaid);
				
				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate,true);
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);
				
				//老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate,false);
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);
				
				
				//通过商品查价格，缓存该商品规格数据
				getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				
				//修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				ProductAllPriceBean productAllPriceBeanUpdate2 = ProductPriceCallService.updatePriceInMgo(productAllPriceBeanUpdate,inaid);
				
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);
				
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
//				productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate2,true);
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);
				
				//老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate2 = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate2,false);
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate2);
			
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIds_004() {
		Logger.start(true, "交易隔离,非新人活动");
		try {

			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndIsolation();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele->catalogs.add(ele.getCatalogId()));
			
			//1 码头新客户 查询结果为普通商品价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
			JSONObject ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
			
			
			//2码头老客户查询结果为普通商品价格
			//vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
			JSONObject ret2 = getPriceByCatalogIdsCall .callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);

			//not vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
			oldProductPrice = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
			ret2 = getPriceByCatalogIdsCall .callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);

			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于缓存里面没有该商品记录，所以结果应该查数据库
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean,inaid);
				
				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate,true);
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);
				
				//老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate,false);
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);
				
				
				//通过商品查价格，缓存该商品规格数据
				getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				
				//修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				ProductAllPriceBean productAllPriceBeanUpdate2 = ProductPriceCallService.updatePriceInMgo(productAllPriceBeanUpdate,inaid);
				
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);
				
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
//				productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate2,true);
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);
				
				//老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate2 = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate2,false);
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate2);
			
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIds_005() {
		Logger.start(true, "普通商品");
		try {

			String productId = ProductPriceCallService.getProductIdWithAllPrice();
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProductAllPrice(productId,0);
			
			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele->catalogs.add(ele.getCatalogId()));
		
			//1 码头新客户 查询结果为普通商品价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
			JSONObject ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
			
			
			//2码头老客户查询结果为普通商品价格
			//vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
			JSONObject ret2 = getPriceByCatalogIdsCall .callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);

			//not vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
			oldProductPrice = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
			ret2 = getPriceByCatalogIdsCall .callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);

			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于缓存里面没有该商品记录，所以结果应该查数据库
				//int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean);
				
				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate,true);
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);
				
				//老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate,false);
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);
				
				
				//通过商品查价格，缓存该商品规格数据
				getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				
				//修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				ProductAllPriceBean productAllPriceBeanUpdate2 = ProductPriceCallService.updatePriceInMgo(productAllPriceBeanUpdate);
				
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);
				
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
//				productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate2,true);
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);
				
				//老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate2 = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate2,false);
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate2);
			
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIds_005_01() {
		Logger.start(true, "普通商品 多规格 查其中一个规格");
		try {

			String productId = ProductPriceCallService.getProductIdWithAllPrice();
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProductAllPrice(productId,0);
			
			getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			
			CatalogAllPriceBean catalogBean = productAllPriceBean.getCatalogAllPriceBeans().get(0);
			String catalog = catalogBean.getCatalogId();
			productAllPriceBean.setCatalogAllPriceBeans(Arrays.asList(catalogBean));
			
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
			JSONObject ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, Arrays.asList(catalog));
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
			
		}catch(Exception e){
			Logger.fail(e);
			
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIds_005_02() {
		Logger.start(true, "两个普通商品 多规格 查其中一个规格");
		try {

			String productId = ProductPriceCallService.getProductIdWithAllPrice();
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProductAllPrice(productId,0);
			getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			CatalogAllPriceBean catalogBean = productAllPriceBean.getCatalogAllPriceBeans().get(0);
			String catalog = catalogBean.getCatalogId();
			productAllPriceBean.setCatalogAllPriceBeans(Arrays.asList(catalogBean));
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
			
			String productId2 = ProductPriceCallService.getProductIdWithAllPrice();
			ProductAllPriceBean productAllPriceBean2 = ProductPriceCallService.getProductAllPrice(productId2,0);
			getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId2);
			CatalogAllPriceBean catalogBean2 = productAllPriceBean2.getCatalogAllPriceBeans().get(0);
			String catalog2 = catalogBean2.getCatalogId();
			productAllPriceBean2.setCatalogAllPriceBeans(Arrays.asList(catalogBean2));
			ProductPriceBean newProductPrice2 = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean2,true);
			
			
			JSONObject ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, Arrays.asList(catalog,catalog2));
			JSONArray CatalogPriceListArray = (JSONArray)ret.getJSONObject("Data").remove("CatalogPriceList");
			Logger.verifyEquals(2, CatalogPriceListArray.length(), "返回规格价格数量为2");
			
			
			JSONObject a;
			JSONObject b;
			if (CatalogPriceListArray.getJSONObject(0).getString("ProductId").equals(productId)){
				a = CatalogPriceListArray.getJSONObject(0);
				b = CatalogPriceListArray.getJSONObject(1);
			}else{
				a = CatalogPriceListArray.getJSONObject(1);
				b = CatalogPriceListArray.getJSONObject(0);
			}
			
			
			ret.getJSONObject("Data").put("CatalogPriceList", new JSONArray());
			ret.getJSONObject("Data").getJSONArray("CatalogPriceList").put(a);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
			
			
			ret.getJSONObject("Data").remove("CatalogPriceList");
			ret.getJSONObject("Data").put("CatalogPriceList", new JSONArray());
			ret.getJSONObject("Data").getJSONArray("CatalogPriceList").put(b);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice2);
			
		}catch(Exception e){
			Logger.fail(e);
			
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIds_006() {
		Logger.start(true, "活动结束，应显示原价");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele->catalogs.add(ele.getCatalogId()));
			
		
			//1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
			JSONObject ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
			
			//2码头老客户查询结果为活动价格
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,false);
			JSONObject ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库活动商品结束时间，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				//activityProductsWapper.update(inaid, MapUtil.hashMap("end",YMTDateUtil.getBeforeOrNextDate(-1)));
				AdminCallService.closeProductInActivity(String.valueOf(inaid));
				
				
				//新客修改后价格检查
				YMTDateUtil.waitTime(2);
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);
				
				//老客修改后价格检查
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);
				
				
				//not vip
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
				oldProductPrice = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
				ret2 = getPriceByCatalogIdsCall .callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			}
		}catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIds_007() {
		Logger.start(true, "活动库存为0，应显示原价");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele->catalogs.add(ele.getCatalogId()));
			
		
			//1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
			JSONObject ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
			
			//2码头老客户查询结果为活动价格
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,false);
			JSONObject ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库活动库存，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductPriceCallService.updateActivityStockTo0InMgo(productAllPriceBean, inaid);
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);

				ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);
				
				//老客修改后价格检查
				//vip
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);
				
				//not vip
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
				oldProductPrice = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
				ret2 = getPriceByCatalogIdsCall .callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);

			}
		}catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Ignore
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIds_008() {
		Logger.start(true, "删除时间戳表后，查询");
		try{
			if (PriceConfig.isCacheCheck){
				ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
				String productId = productAllPriceBean.getProductId();
				List<String> catalogs = new ArrayList<>();
				productAllPriceBean.getCatalogAllPriceBeans().forEach(ele->catalogs.add(ele.getCatalogId()));
				
				
				//删除时间戳表记录
				productTimeStampWapper.delete(productId);
				
				//1 码头新客户 查询结果为活动价格
				ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
				JSONObject ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
				
				//2码头老客户查询结果为活动价格
				ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,false);
				JSONObject ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
			
				//修改 Mongo 数据库活动库存
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductPriceCallService.updateActivityStockTo0InMgo(productAllPriceBean, inaid);
				
				YMTDateUtil.waitTime(5);
				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
				ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);
				
				//老客修改后价格检查
				//vip
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
				ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);
				
				
				//not vip
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
				oldProductPrice = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
				ret2 = getPriceByCatalogIdsCall .callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);

				
			}
			
			
			
			
		}catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIds_009() {
		Logger.start(true, "非交易隔离,会员活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation_Member();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();
			
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele->catalogs.add(ele.getCatalogId()));
			
			Map<String,Integer> catalogsMap = new HashMap<>();
			catalogs.forEach(ele->catalogsMap.put(ele, 1));
			
			int prodInActivityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			
			//新客 普通价
			ProductPriceBean priceIgnoreActivity_NewCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
			//新客 会员价
			ProductPriceBean priceIncludeActivity_NewCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
			//老客 普通价
			ProductPriceBean priceIgnoreActivity_OleCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,false);
			//老客 会员价
			ProductPriceBean priceIncludeActivity_OleCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,false);
			
			
			//会员政策1， 会员等级3以上才能享受活动价
			
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 1, "3,4,5,6");
			//0级会员 新客 普通价
			JSONObject ret1 = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret1, priceIgnoreActivity_NewCust);
			
			JSONObject ret1_1 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData(newBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret1_1, priceIgnoreActivity_NewCust);
			
			JSONObject ret1_2 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData2(newBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret1_2, priceIgnoreActivity_NewCust);
			
			
			//6级会员  老客 会员活动价
			JSONObject ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, priceIncludeActivity_OleCust);
			
			JSONObject ret2_1 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData(oldBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret2_1, priceIncludeActivity_OleCust);
			
			JSONObject ret2_2 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData2(oldBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret2_2, priceIncludeActivity_OleCust);
			
			//会员政策2，会员注册时间在2017-01-02 到 2017-03-23 才能享受活动价
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 2, "2015-01-02 00:00:00,2016-03-23 23:59:59");
			
			//新客 注册时间2015-05-26 14:20:04 会员活动价
			JSONObject ret3 = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret3, priceIncludeActivity_NewCust);
			
			JSONObject ret3_1 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData(newBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret3_1, priceIncludeActivity_NewCust);

			JSONObject ret3_2 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData2(newBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret3_2, priceIncludeActivity_NewCust);
			
			
			//老客 注册时间2016-04-22 10:19:05 普通价格
			JSONObject ret4 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret4, priceIgnoreActivity_OleCust);
			
			JSONObject ret4_1 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData(oldBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret4_1, priceIgnoreActivity_OleCust);
			
			JSONObject ret4_2 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData2(oldBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret4_2, priceIgnoreActivity_OleCust);
			   
			//会员政策3， 会员标签满足才能享受活动价  标签值 3 
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId,3, "3");
			
			//新客  标签3  会员活动价
			JSONObject ret5 = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret5, priceIncludeActivity_NewCust);
			
			JSONObject ret5_1 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData(newBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret5_1, priceIncludeActivity_NewCust);
			
			JSONObject ret5_2 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData2(newBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret5_2, priceIncludeActivity_NewCust);
			
			//老客 没标签 普通价格
			JSONObject ret6 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret6, priceIgnoreActivity_OleCust);
			
			JSONObject ret6_1 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData(oldBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret6_1, priceIgnoreActivity_OleCust);
			
			JSONObject ret6_2 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData2(oldBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret6_2, priceIgnoreActivity_OleCust);
			
			//会员政策3， 会员标签满足才能享受活动价  标签值 4
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId,3, "4");
			
			//新客  标签3  普通价
			JSONObject ret7 = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret7, priceIgnoreActivity_NewCust);
			
			JSONObject ret7_1 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData(newBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret7_1, priceIgnoreActivity_NewCust);
			
			JSONObject ret7_2 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData2(newBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret7_2, priceIgnoreActivity_NewCust);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIds_010() {
		Logger.start(true, "交易隔离,会员活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndIsolation_Member();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele->catalogs.add(ele.getCatalogId()));
			
			Map<String,Integer> catalogsMap = new HashMap<>();
			catalogs.forEach(ele->catalogsMap.put(ele, 1));
			
			int prodInActivityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			
			//新客 普通价
			ProductPriceBean priceIgnoreActivity_NewCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,true);
			//老客 普通价
			ProductPriceBean priceIgnoreActivity_OleCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,true);
			
			//会员政策1， 会员等级3以上才能享受活动价
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 1, "3,4,5,6");
			//0级会员 新客 普通价
			JSONObject ret1 = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret1, priceIgnoreActivity_NewCust);
			
			
			JSONObject ret1_1 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData(newBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret1_1, priceIgnoreActivity_NewCust);
			
			JSONObject ret1_2 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData2(newBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret1_2, priceIgnoreActivity_NewCust);
			
			//6级会员  老客 普通价
			JSONObject ret2 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, priceIgnoreActivity_OleCust);
			
			JSONObject ret2_1 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData(oldBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret2_1, priceIgnoreActivity_OleCust);
			
			JSONObject ret2_2 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData2(oldBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret2_2, priceIgnoreActivity_OleCust);
			
			//会员政策2，会员注册时间在2017-01-02 到 2017-03-23 才能享受活动价
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 2, "2015-01-02 00:00:00,2016-03-23 23:59:59");
			
			//新客 注册时间2015-05-26 14:20:04 普通价
			JSONObject ret3 = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret3, priceIgnoreActivity_NewCust);
			
			JSONObject ret3_1 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData(newBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret3_1, priceIgnoreActivity_NewCust);
			
			JSONObject ret3_2 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData2(newBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret3_2, priceIgnoreActivity_NewCust);
			
			//老客 注册时间2016-04-22 10:19:05 普通价格
			JSONObject ret4 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret4, priceIgnoreActivity_OleCust);
			
			JSONObject ret4_1 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData(oldBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret4_1, priceIgnoreActivity_OleCust);
			
			JSONObject ret4_2 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData2(oldBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret4_2, priceIgnoreActivity_OleCust);
			
			//会员政策3， 会员标签满足才能享受活动价  标签值 3 
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId,3, "3");
			
			//新客  标签3  普通价
			JSONObject ret5 = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret5, priceIgnoreActivity_NewCust);
			
			JSONObject ret5_1 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData(newBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret5_1, priceIgnoreActivity_NewCust);
			
			JSONObject ret5_2 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData2(newBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret5_2, priceIgnoreActivity_NewCust);
			
			//老客 没标签 普通价格
			JSONObject ret6 = getPriceByCatalogIdsCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret6, priceIgnoreActivity_OleCust);
			
			JSONObject ret6_1 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData(oldBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret6_1, priceIgnoreActivity_OleCust);
			
			JSONObject ret6_2 = getCatalogPriceListByDeliveryExtraCall.callAndGetReturnData2(oldBuyerId, catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret6_2, priceIgnoreActivity_OleCust);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	

	
	
	
	
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIds_999() {
		Logger.start(true, "非法数据测试");
		try {
			//不存在 商品id
			JSONObject ret = getPriceByCatalogIdsCall.callAndGetReturnData(newBuyerId, Arrays.asList("111212312"));
			Logger.verifyEquals(201, ret.getInt("Code"), "返回报文 Code字段检查");
			ProductPriceCallService.checkInvalidResponse(ret);
			
			
			//buyer id<0
			String productId = ProductPriceCallService.getProductIdWithAllPrice();
			JSONObject ret1 = getPriceByCatalogIdsCall.callAndGetReturnData(-1, Arrays.asList(productId));
			Logger.verifyEquals(201, ret.getInt("Code"), "返回报文 Code字段检查");
			ProductPriceCallService.checkInvalidResponse(ret1);
			
			
			
		}catch (Exception e) {
			Logger.fail(e);
		}
	
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIds_100() {
		Logger.start(true, "非交易隔离,新哈尼");
		try {
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequestV2(3383);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			List<String> catalogs = new ArrayList<>();
			List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			ymtCatalogsIList.forEach(ele->catalogs.add(ele.getsCatalogId()));

			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			Integer userId = urrc.getUserid();

			//1 码头新客户 查询结果为活动价格
			JSONObject ret = getPriceByCatalogIdsCall.callAndGetReturnData(userId, catalogs);


		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	

	///////////////// 忽略case ///////////////////////

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_GetPriceByCatalogIds_101() {
		Logger.start(true, "限时抢购查询价格");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,rootUserName,false);
			double price=200;
			addAgentProductBean.getCatalogList().forEach(a->{
				a.getAgentPriceList().forEach(b->{
					b.setAgentPrice(price);
				});
				a.setDirectPrice(price);
			});
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(rootUserId,productId);


			//创建限时抢购活动
			List<String> catalogList =new ArrayList<String>();

			selectProductDetails.getCatalogList().forEach(a->{
				catalogList.add(a.getCatalogId());
			});
			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(rootUserId, productId, catalogList);
			initProductaddactivity.getProductList().forEach(a->{
				a.getCatalogList().forEach(b->{
					b.setDiscount(new BigDecimal("2"));
				});
			});
			int activityId = AgentProductCallService.agentProductaddactivity(initProductaddactivity);

			Thread.sleep(5000);
			//1查询结果为活动价格
			JSONObject callAndGetReturnData = getPriceByCatalogIdsCall.callAndGetReturnData(rootUserId, catalogList);

			JSONArray CatalogPriceList = callAndGetReturnData.getJSONObject("Data").getJSONArray("CatalogPriceList");
			double double1 = CatalogPriceList.getJSONObject(0).getJSONObject("CatalogInfo").getDouble("ActivityPrice");
			double double2 = CatalogPriceList.getJSONObject(1).getJSONObject("CatalogInfo").getDouble("ActivityPrice");

//			ProductDetailsDto selectProductDetails1 = AddAgentProductCallService.selectProductDetails(rootUserId,productId);
			Logger.verifyEquals(40.0, double1, "验证活动价格");
			Logger.verifyEquals(40.0, double2, "验证活动价格");
		} catch (Exception e) {
			Logger.fail(e);
		} finally {
		}
	}


	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_GetPriceByCatalogIds_102() {
		Logger.start(true, "限时抢购查询价格--没有库存的时候");
		try {

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,rootUserName,false);
			double price=200;
			Integer catalogNum11 = 10000;
			addAgentProductBean.getCatalogList().forEach(a->{
				a.getAgentPriceList().forEach(b->{
					b.setAgentPrice(price);
				});
				a.setDirectPrice(price);
				a.setStock(catalogNum11);
			});

			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(rootUserId,productId);


			//创建限时抢购活动
			List<String> catalogList =new ArrayList<String>();

			selectProductDetails.getCatalogList().forEach(a->{
				catalogList.add(a.getCatalogId());
			});
			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(rootUserId, productId, catalogList);
			initProductaddactivity.getProductList().forEach(a->{
				a.getCatalogList().forEach(b->{
					b.setDiscount(new BigDecimal("2"));
				});
			});
			int activityId = AgentProductCallService.agentProductaddactivity(initProductaddactivity);


			//减去所有库存
			int reduceNum =10000;
			PCatalogListDto catalogListDto = ProdStockCallService.ReduceStockListForPreOrder(productId, catalogList.get(0), rootUserId, activityId, reduceNum, 0, true);
			PCatalogListDto catalogListDto1 = ProdStockCallService.ReduceStockListForPreOrder(productId, catalogList.get(1), rootUserId, activityId, reduceNum, 0, true);


			Thread.sleep(5000);
			//1查询结果为活动价格
			JSONObject callAndGetReturnData = getPriceByCatalogIdsCall.callAndGetReturnData(rootUserId, catalogList);

			JSONArray CatalogPriceList = callAndGetReturnData.getJSONObject("Data").getJSONArray("CatalogPriceList");
			double double1 = CatalogPriceList.getJSONObject(0).getJSONObject("CatalogInfo").getDouble("ActivityPrice");
			double double2 = CatalogPriceList.getJSONObject(1).getJSONObject("CatalogInfo").getDouble("ActivityPrice");
			double Price = CatalogPriceList.getJSONObject(1).getJSONObject("CatalogInfo").getDouble("Price");

			Logger.verifyEquals(0.0, double1, "验证活动价格");
			Logger.verifyEquals(0.0, double2, "验证活动价格");
			Logger.verifyEquals(200.0, Price, "验证活动价格");


			ProductDetailsDto selectProductDetails1 = AddAgentProductCallService.selectProductDetails(rootUserId,productId);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}


	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_GetPriceByCatalogIds_103() {
		Logger.start(true, "限时抢购 代理商品查询价格");
		try {
			AddAgentProductBean addAgentProductBean1 = AddAgentProductCallService.initAddAgentProduct(sellerId,sellerName,true);
			double price=200;
			addAgentProductBean1.getCatalogList().forEach(a->{
				a.getAgentPriceList().forEach(b->{
					b.setAgentPrice(price);
				});
				a.setDirectPrice(price);
			});
			String productId1 = AddAgentProductCallService.AddAgentProduct(addAgentProductBean1);
			ImportAgentProductBean addAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId1,sellerId,false);
			
			String productId = AddAgentProductCallService.ImportAgentProduct(addAgentProductBean);

			//创建限时抢购活动
		 	ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(agentUserId1,productId);
		 	double agentPrice = selectProductDetails.getCatalogList().get(0).getDirectPrice();
		 	
			List<String> catalogList =new ArrayList<String>();
			selectProductDetails.getCatalogList().forEach(a->{
		 		catalogList.add(a.getCatalogId());
		 	});
			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(agentUserId1, productId, catalogList);
			initProductaddactivity.getProductList().forEach(a->{
				a.getCatalogList().forEach(b->{
					b.setDiscount(new BigDecimal("2"));
				});
			});
			int activityId = AgentProductCallService.agentProductaddactivity(initProductaddactivity);

			Thread.sleep(5000);
			//1查询结果为活动价格
			JSONObject callAndGetReturnData = getPriceByCatalogIdsCall.callAndGetReturnData(agentUserId1, catalogList);

			JSONArray CatalogPriceList = callAndGetReturnData.getJSONObject("Data").getJSONArray("CatalogPriceList");
			double double1 = CatalogPriceList.getJSONObject(0).getJSONObject("CatalogInfo").getDouble("ActivityPrice");
			double double2 = CatalogPriceList.getJSONObject(1).getJSONObject("CatalogInfo").getDouble("ActivityPrice");

//			ProductDetailsDto selectProductDetails1 = AddAgentProductCallService.selectProductDetails(rootUserId,productId);
			Logger.verifyEquals(agentPrice*0.2, double1, "验证活动价格");
			Logger.verifyEquals(agentPrice*0.2, double2, "验证活动价格");
		} catch (Exception e) {
			Logger.fail(e);
		} 
	}
	


}
